package com.qf.commerce.controller;

import com.qf.commerce.entity.Classify;
import com.qf.commerce.resp.ResponseResult;
import com.qf.commerce.service.ClassifyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author peng
 * @Date 2023/9/13 16:24
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/classify")
public class ClassifyController {
    @Autowired
    private ClassifyService classifyService;
//    分类表展示
    @GetMapping("/select")
    public ResponseResult<List<Classify>> selectClassify(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "2") int size, Classify classify) {
        return ResponseResult.success(classifyService.selectClassify(page, size, classify));
    }

    //    添加分类
    @PostMapping("/addclassify")
    public ResponseResult<Integer> addClassify(@RequestBody Classify classify) {
        return ResponseResult.success(classifyService.addClassify(classify));
    }

    //    修改商品分类
    @PutMapping("/update")
    public ResponseResult<Integer> updateClassify(@RequestBody Classify classify) {
        return ResponseResult.success(classifyService.updateClassify(classify));
    }

    //    根据id删除单条店铺分类数据
    @DeleteMapping("/deleteClassifyId")
    public ResponseResult<Integer> deleteClassify(Long classifyId) {
        return ResponseResult.success(classifyService.deleteClassify(classifyId));
    }

    //    根据id 删除多条店铺分类数据
    @DeleteMapping("/deleteClassifyById")
    public ResponseResult<Integer> deleteClassifyListById(@RequestBody List<Long> classifyById) {
        return ResponseResult.success(classifyService.deleteClassifyListById(classifyById));
    }
}
